package chap01;

class Demo2Thread implements  Runnable{

    @Override
    public void run() {
        for(int i = 0 ;i< 10;i++){
            System.out.println(Thread.currentThread().getName()+":"+i);
        }
    }
}


public class Demo2 {
    public static void main(String[] args) {
        Thread th= new Thread(new Demo2Thread());
        th.start();
        for(int i = 0 ;i<50;i++){
            if(i>10){
                //i > 0 ;强制运行th
                try {
                    th.join();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("main:" + i);
        }
    }
}
